<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * Smarty {restaurant_type_3} function plugin
 * @param array|null $params
 * @param Smarty $smarty
 */
function smarty_function_restaurant_column_1($params, $smarty) {
    if (!isset($params)) {
        return ;
    }

    if (isset($params['limit'])) {
        $limit = $params['limit'];
    } else {
        $limit = 4;
    }

    $filters = array('limit' => $limit);
    $smarty->CI->load->model('restaurant/restaurant_model');
    $data = $smarty->CI->restaurant_model->get_restaurants($filters);
    if (!$data) {
        return '';
    }

    $ci =& get_instance();
    $ci->load->helper('text');
    $html = '';
    foreach ($data as $item) {
        $intro = word_limiter($item['introtext'], 50);

        $html .= "<div class='update-foodee-event-item'>
                <div style='float: left;'>
                    <a href=\"{$item['link']}\" class=\"goEventPopup\" title=\"{$item['name']}\">
                    <img src=\"{$item['image3']}\" alt=\"\" title=\"\" style=\"width: 318px; height: 100px;\">
                    </a>
                </div>
                <div style=\"clear: both; margin-top: 10px; float: left; width: 320px;\">
                    <div style=\"float: right; padding: 10px;\">
                        <div class=\"item-name\" style=\"font-weight: bold; font-size: 16px; line-height: 1.2em;\">
                            <a href=\"{$item['link']}\" class=\"goEventPopup\" title=\"{$item['name']}\"> {$item['name']} </a>
                        </div>
                        <div style=\"padding-top: 5px; float: left; color: #777; float: left;\">
                            <p>
                                {$intro}
                            </p>
                        </div>
                    </div>
                </div>
                <div style=\"padding: 10px; float: left; width: 298px; border-top: #eee 1px solid; margin-top: 10px;\">
                    <div style=\"float: left; width: 200px; color: #777; font-size: 11px;\">
                        <div style=\"padding-bottom: 2px;\">
                            {$item['address']}, {$item['pref_name']}
                        </div>
                    </div>
                    <div style=\"float: right;\">
                        <a href=\"{$item['link']}\" class=\"event-registry-btn\">Xem chi tiết</a>
                    </div>
                </div>
            </div>";
    }
    return $html;
}
